home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / graphics / gnuplot / term / hppj.trm < prev    next >
Text File  |  1993-09-15  |  6KB  |  210 lines

  1. /*
  2.  * $Id: hppj.trm%v 3.50.1.11 1993/08/10 03:55:03 woo Exp $
  3.  *
  4.  */
  5.  
  6. /* GNUPLOT - hppj.trm */
  7. /*
  8.  * Copyright (C) 1990   
  9.  *
  10.  * Permission to use, copy, and distribute this software and its
  11.  * documentation for any purpose with or without fee is hereby granted, 
  12.  * provided that the above copyright notice appear in all copies and 
  13.  * that both that copyright notice and this permission notice appear 
  14.  * in supporting documentation.
  15.  *
  16.  * Permission to modify the software is granted, but not the right to
  17.  * distribute the modified code.  Modifications are to be distributed 
  18.  * as patches to released version.
  19.  *  
  20.  * This software  is provided "as is" without express or implied warranty.
  21.  * 
  22.  * This file is included by ../term.c.
  23.  *
  24.  * This terminal driver supports:
  25.  *  hppj
  26.  *
  27.  * AUTHORS
  28.  *  Dan Merget (danm@sr.hp.com)
  29.  *
  30.  * This file was based on the hpljii file by:
  31.  *  John Engels
  32.  *  Russell Lang
  33.  *  Maurice Castro
  34.  *
  35.  * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
  36.  * 
  37.  */
  38.  
  39. /* The following HP laserjet series II driver uses generic bit mapped graphics
  40.  * routines from bitmap.c to build up a bit map in memory.
  41.  */
  42.  
  43. #ifdef HPPJ
  44.  
  45. /* We define 3 different font sizes: 5x9, 9x17, and 13x25 */
  46.  
  47. #define HPPJ_DPI 180   /* dots per inch */
  48. #define HPPJ_PLANES 3  /* color planes */
  49. #define HPPJ_COLORS (1 << HPPJ_PLANES)
  50. /* make XMAX and YMAX a multiple of 8 */
  51. #define HPPJ_XMAX (8*(unsigned int)(9.5 * HPPJ_DPI / 8.0 + 0.9))
  52. #define HPPJ_YMAX (8 * HPPJ_DPI)
  53.  
  54. /* default values for term_tbl */
  55. #define HPPJ_9x17_VCHAR FNT9X17_VCHAR
  56. #define HPPJ_9x17_HCHAR FNT9X17_HCHAR
  57. #define HPPJ_9x17_VTIC (FNT9X17_VCHAR / 2)
  58. #define HPPJ_9x17_HTIC (FNT9X17_HCHAR / 2)
  59.  
  60. static int hppj_font = FNT9X17;
  61.  
  62. HPPJoptions()
  63. {
  64.     char opt[10];
  65. #define HPPJERROR "expecting font size FNT5X9, FNT9X17, or FNT13X25"
  66.  
  67.     term_options[0]='\0'; /* default to empty string and 9x17 font */
  68.     hppj_font = FNT9X17;  /* in case of error or empty options     */
  69.  
  70.     if ( !END_OF_COMMAND ) {
  71.         if ( token[c_token].length > 8 ) {
  72.             int_error(HPPJERROR, c_token);
  73.        }
  74.  
  75.         capture(opt, c_token, c_token);
  76.         if ( !strcmp(opt, "FNT5X9") ) {
  77.             hppj_font = FNT5X9;
  78.             strcpy(term_options, "FNT5X9");
  79.     } else if ( !strcmp(opt, "FNT9X17") ) {
  80.            hppj_font = FNT9X17;
  81.             strcpy(term_options, "FNT9X17");
  82.     } else if ( !strcmp(opt, "FNT13X25") ) {
  83.            hppj_font = FNT13X25;
  84.             strcpy(term_options, "FNT13X25");
  85.     } else {
  86.         int_error(HPPJERROR, c_token);
  87.     }
  88.     c_token++;
  89.     }
  90. }
  91.  
  92.  
  93. HPPJinit()
  94. {
  95. #ifdef REOPEN_BINARY
  96.     reopen_binary();
  97. #endif
  98. }
  99.  
  100.  
  101. HPPJreset()
  102. {
  103. #ifdef vms
  104.     fflush_binary();
  105. #endif /* vms */
  106. }
  107.  
  108.  
  109. HPPJgraphics()
  110. {
  111.     switch ( hppj_font ) {
  112.       case FNT5X9 :
  113.     term_tbl[term].v_char = FNT5X9_VCHAR;
  114.     term_tbl[term].h_char = FNT5X9_HCHAR;
  115.     term_tbl[term].v_tic = FNT5X9_VCHAR / 2;
  116.     term_tbl[term].h_tic = FNT5X9_HCHAR / 2;
  117.     break;
  118.       case FNT9X17 :
  119.     term_tbl[term].v_char = FNT9X17_VCHAR;
  120.     term_tbl[term].h_char = FNT9X17_HCHAR;
  121.     term_tbl[term].v_tic = FNT9X17_VCHAR / 2;
  122.     term_tbl[term].h_tic = FNT9X17_HCHAR / 2;
  123.     break;
  124.       case FNT13X25 :
  125.     term_tbl[term].v_char = FNT13X25_VCHAR;
  126.     term_tbl[term].h_char = FNT13X25_HCHAR;
  127.     term_tbl[term].v_tic = FNT13X25_VCHAR / 2;
  128.     term_tbl[term].h_tic = FNT13X25_HCHAR / 2;
  129.     break;
  130.     }
  131.     b_charsize(hppj_font);
  132.  
  133.     b_makebitmap(HPPJ_XMAX, HPPJ_YMAX, HPPJ_PLANES);
  134. }
  135.  
  136.  
  137. HPPJtext()
  138. {
  139.     int x, plane, y;    /* loop indexes */
  140.     int minRow, maxRow;    /* loop bounds */
  141.     int numBytes;    /* Number of run-length coded bytes to output */
  142.     int numReps;    /* Number of times the current byte is repeated */
  143.  
  144.     fprintf(outfile, "\033E\033*t%dR\033*r%dS", HPPJ_DPI, HPPJ_YMAX);
  145.     fprintf(outfile, "\033*b0X\033*b0Y\033*r%dU", HPPJ_PLANES);
  146.     fprintf(outfile, "\033*v%dA\033*v%dB\033*v%dC\033*v%dI", 90, 88, 85, 0);
  147.     fprintf(outfile, "\033*v%dA\033*v%dB\033*v%dC\033*v%dI", 53,  8, 14, 1);
  148.     fprintf(outfile, "\033*v%dA\033*v%dB\033*v%dC\033*v%dI",  3, 26, 22, 2);
  149.     fprintf(outfile, "\033*v%dA\033*v%dB\033*v%dC\033*v%dI",  4,  4, 29, 3);
  150.     fprintf(outfile, "\033*v%dA\033*v%dB\033*v%dC\033*v%dI", 53,  5, 25, 4);
  151.     fprintf(outfile, "\033*v%dA\033*v%dB\033*v%dC\033*v%dI",  2, 22, 64, 5);
  152.     fprintf(outfile, "\033*v%dA\033*v%dB\033*v%dC\033*v%dI", 89, 83, 13, 6);
  153.     fprintf(outfile, "\033*v%dA\033*v%dB\033*v%dC\033*v%dI",  4,  4,  6, 7);
  154.     fprintf(outfile, "\033*b1M\033*r1A");
  155.  
  156.     /* dump bitmap in raster mode using run-length encoding */
  157.     for ( x = HPPJ_XMAX - 1 ; x >= 0 ; --x ) {
  158.         for ( plane = 0 ; plane < HPPJ_PLANES ; plane++ ) {
  159.             minRow = b_psize * plane;
  160.             maxRow = b_psize * plane + b_psize - 1;
  161.  
  162.             /* Print column header */
  163.             numBytes = 0;
  164.             for ( y = maxRow ; y >= minRow ; --y ) {
  165.                 if ( y == minRow || *((*b_p)[y]+x) != *((*b_p)[y-1]+x) ) {
  166.                     numBytes += 2;
  167.                 }
  168.             }
  169.             fprintf(outfile, "\033*b%d", numBytes);
  170.             (void) fputc((char)(plane < HPPJ_PLANES - 1 ? 'V' : 'W'), outfile);
  171.  
  172.             /* Print remainder of column */
  173.             numReps = 0;
  174.             for ( y = maxRow ; y >= minRow ; --y ) {
  175.                 if ( y == minRow || *((*b_p)[y]+x) != *((*b_p)[y-1]+x) ) {
  176.                     (void) fputc( (char)(numReps), outfile );
  177.                     (void) fputc( (char)(*((*b_p)[y]+x)), outfile );
  178.                     numReps = 0;
  179.                 } else {
  180.                     numReps++;
  181.                 }
  182.             }
  183.         }
  184.     }
  185.     fprintf(outfile, "\033*r1B\033E");
  186.  
  187.     b_freebitmap();
  188. }
  189.  
  190.  
  191. HPPJlinetype(linetype)
  192.     int linetype;
  193. {
  194.     if ( linetype >= 0 ) {
  195.         b_setlinetype(0);
  196.         b_setvalue((linetype % (HPPJ_COLORS-1)) + 1);
  197.     } else {
  198.         b_setlinetype(linetype + 2);
  199.         b_setvalue(HPPJ_COLORS - 1);
  200.     }
  201. }
  202.  
  203.  
  204. #define HPPJmove       b_move
  205. #define HPPJvector     b_vector
  206. #define HPPJtext_angle b_text_angle
  207. #define HPPJput_text   b_put_text
  208.  
  209. #endif /* HPPJ */
  210.